package com.bwie.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bwie.pojo.User;
import com.bwie.service.UserService;
import com.bwie.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Mikey
 * @Date: 2025/9/9 09:28
 * @Description:
 **/
@RestController
@RequestMapping("user/index")
public class UserController {

    @Autowired
    private UserService userService;


    /***
     * @author: 秋晚
     * @description:根据手机号查询用户
     * @params: [java.lang.String]
     * @return: com.bwie.utils.R
     * @date: 2025/9/9 9:30
     */
    @GetMapping("getUserByphone/{phone}")
    public User getUserByPhone(@PathVariable(name = "phone")String phone){
        //根据手机号查询返回用户
        User user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getPhone, phone));
        //返回
        return user;
    }


    /***
     * @author: 秋晚
     * @description:根据id获取用户信息
     * @params: [java.lang.Integer]
     * @return: com.bwie.pojo.User
     * @date: 2025/9/9 11:55
     */
    @GetMapping("getUserById/{id}")
    public User getUserById(@PathVariable(name = "id")Integer id){
        return userService.getById(id);
    }
}
